package org.mango.dsaa.demo;

import com.alibaba.fastjson.JSONObject;

import java.util.TreeSet;

/**
 * TreeSet 实现基于TreeMap，插入数据时会排序
 * 运行结果：
 * ["123","2你是谁","321","aaa","ddd","中国","啊"]
 */
public class TreeSetDemo {
    public static void main(String[] args) {
        TreeSet treeSet = new TreeSet();
        treeSet.add("123");
        treeSet.add("321");
        treeSet.add("ddd");
        treeSet.add("啊");
        treeSet.add("2你是谁");
        treeSet.add("aaa");
        treeSet.add("中国");
        System.out.println(JSONObject.toJSONString(treeSet));
    }
}
